package com.xcc.strategypattern.demo03;

/**
 * @Description: 职责描述
 * @Author: xiechuang
 * @Date: 2022/5/20
 */
public abstract class Duck {

    public Duck() {}

    FlyBehavior flyBehavior;

    QuackBehavior quackBehavior;

    /**
     * 设定飞翔行为
     *
     * @param flyBehavior
     */
    public void setFlyBehavior(FlyBehavior flyBehavior) {
        this.flyBehavior = flyBehavior;
    }

    /**
     * 设定叫声行为
     *
     * @param quackBehavior
     */
    public void setQuackBehavior(QuackBehavior quackBehavior) {
        this.quackBehavior = quackBehavior;
    }

    /**
     * 游泳
     */
    public void swim() {
        System.out.println("游泳");
    }

    /**
     * 外观
     */
    public abstract void display();

    /**
     * 代理：叫声
     */
    public void performQuack() {
        quackBehavior.quack();
    }

    /**
     * 代理：飞翔
     */
    public void performFly() {
        flyBehavior.fly();
    }

}
